<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property integer $task_id 任务执行标识
 * @property integer $device_id 设备uid
 * @property integer $signal_id 信号id
 * @property integer $field_type 数据类型
 * @property integer $collect_task_id 任务id
 * @property string $address 信号地址
 * @property string $value 采集值
 * @property integer $status 采集状态
 * @property string $reason 错误说明
 * @property string $collect_time 采集时间
 * @property string $create_time 创建时间
 */
class IotCollectDatum extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'iot_collect_data';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    protected $appends=[
        'field_name'
    ];
    public function getFieldNameAttribute()
    {
        $signal_id = $this->signal_id;
        $data = IotSignal::find($signal_id);
        $string="--";
        if ($data){
            $string =$data->field_name."【".$data->name."】";
        }
        return $string;
    }

}
